package com.briup.mt.web.controller;

import com.briup.mt.bean.BaseUserRole;
import com.briup.mt.service.IBaseUserRoleService;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import com.briup.mt.utils.MessageUtil;
import com.briup.mt.utils.Message;
import javax.validation.constraints.NotNull;
import java.util.List;
@RestController
@Validated
@RequestMapping("/baseUserRole")
public class BaseUserRoleController {
    @Autowired
    private IBaseUserRoleService baseUserRoleService;
    @GetMapping("findById")
    public  Message findById(long id){
        BaseUserRole baseUserRole=baseUserRoleService.findById(id);
        return MessageUtil.success(baseUserRole);
    }
    @GetMapping("query")
    public Message query(Long userId,Long roleId){
        List<BaseUserRole> list =  baseUserRoleService.query(userId,roleId);
        return MessageUtil.success(list);
    }

    @PostMapping("saveOrUpdate")
    public Message saveOrUpdate(BaseUserRole baseUserRole){
       baseUserRoleService.saveOrUpdate(baseUserRole);
        return MessageUtil.success("操作成功");
    }

    @DeleteMapping("deleteById")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "id", value = "角色编号", required = true, paramType = "query"),
    })
    public Message deleteById(@RequestParam @NotNull Long id){
        baseUserRoleService.deleteById(id);
        return MessageUtil.success("操作成功");
    }
}
